package org.wxd.media.api.record;

import org.apache.commons.lang3.builder.ToStringBuilder;

import java.util.Map;

/**
 * Created by wangxd on 2016/11/1.
 */
public class MediaRecord {
    private String id;
    private String name;
    private String checksum;
    private Boolean thumbnail;
    private Long createTime;
    private Long expireTime;
    private Long size;
    private String suffix;
    private String contentType;

    private Map<String, String> moreInfo;


    MediaRecord() {
    }

    private MediaRecord(Builder builder) {
        this.id = builder.id;
        this.name = builder.name;
        this.checksum = builder.checksum;
        this.thumbnail = builder.thumbnail;
        this.contentType = builder.contentType;
        this.createTime = builder.createTime;
        this.expireTime = builder.expireTime;
        this.size = builder.size;
        this.suffix = builder.suffix;
        this.moreInfo = builder.moreInfo;
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public String id() {
        return id;
    }

    public String name() {
        return name;
    }

    public String checksum() {
        return checksum;
    }

    public Long createTime() {
        return createTime;
    }

    public Long expireTime() {
        return expireTime;
    }

    public Long size() {
        return size;
    }

    public String suffix() {
        return suffix;
    }

    public Boolean isThumbnail() {
        return thumbnail;
    }

    public String contentType() {
        return contentType;
    }

    public Map<String, String> moreInfo() {
        return moreInfo;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }


    public static class Builder {
        private String id;
        private String name;
        private String checksum;
        private Boolean thumbnail = false;
        private Long createTime = System.currentTimeMillis();
        private Long expireTime = -1L;
        private Long size;
        private String suffix;

        private String contentType;
        private Map<String, String> moreInfo;


        public MediaRecord build() {
            return new MediaRecord(this);
        }

        public Builder id(String id) {
            this.id = id;
            return this;
        }

        public Builder name(String name) {
            this.name = name;
            return this;
        }

        public Builder createTime(Long createTime) {
            this.createTime = createTime;
            return this;
        }

        public Builder expireTime(Long expireTime) {
            this.expireTime = expireTime;
            return this;
        }

        public Builder size(Long size) {
            this.size = size;
            return this;
        }

        public Builder suffix(String suffix) {
            this.suffix = suffix;
            return this;
        }

        public Builder thumbnail(Boolean thumbnail) {
            this.thumbnail = thumbnail;
            return this;
        }

        public Builder contentType(String contentType) {
            this.contentType = contentType;
            return this;
        }

        public Builder checksum(String checksum) {
            this.checksum = checksum;
            return this;
        }

        public Builder moreInfo(Map<String, String> moreInfo) {
            this.moreInfo = moreInfo;
            return this;
        }
    }
}
